package WaiBao;

import java.util.Arrays;
import java.util.Scanner;
public class candy1 {
    public static boolean function(int n,int []arr){
        for (int i = 0; i < arr.length; i++) {
            if(n == arr[i]){
                return true;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        int []arr = {1,2,3,39,52,61,43,34,24,42,48,148,14,19,47,357,146,189,259,454};
        System.out.println("请输入你要查找的数:");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //排序
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i; j < arr.length-i-1; j++) {
                if(arr[j] > arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
        System.out.println("排序后");
        System.out.println(Arrays.toString(arr));
        System.out.println("数n是否在数组中？"+function(n,arr));
    }
}
